package com.xhwl.logistics.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.xhwl.common.pojo.ResultJson;
import com.xhwl.logistics.bo.VehiclePayRecordBO;
import com.xhwl.logistics.bo.input.PageBO;
import com.xhwl.logistics.bo.input.QueryVehiclePayRecordBO;
import com.xhwl.logistics.converter.ToPageBO;
import com.xhwl.logistics.converter.ToPageVO;
import com.xhwl.logistics.converter.ToQueryVehiclePayRecordBO;
import com.xhwl.logistics.converter.ToVehiclePayRecordVO;
import com.xhwl.logistics.dto.query.VehiclePayRecordDTO;
import com.xhwl.logistics.service.IVehiclePayRecordService;
import com.xhwl.logistics.vo.PageVO;
import com.xhwl.logistics.vo.VehiclePayRecordVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;

//@RestController
public class VehiclePayRecordController {

    @Autowired
    private IVehiclePayRecordService vehiclePayRecordService;

    @Autowired
    private ToQueryVehiclePayRecordBO toQueryVehiclePayRecordBO;

    @Autowired
    private ToPageBO toPageBO;

    @Autowired
    private ToVehiclePayRecordVO toVehiclePayRecordVO;

    @Autowired
    private ToPageVO toPageVO;

    @PostMapping("/pay-record/page")
    public ResultJson<PageVO<VehiclePayRecordVO>> payRecord(@RequestBody VehiclePayRecordDTO vehiclePayRecordDTO) {
        QueryVehiclePayRecordBO queryVehiclePayRecordBO = toQueryVehiclePayRecordBO.toQueryVehiclePayRecordBO(vehiclePayRecordDTO);
        PageBO pageBO = toPageBO.toPageBO(vehiclePayRecordDTO);

        Page<VehiclePayRecordBO> vehiclePayRecordBOPage = vehiclePayRecordService.pagePayRecord(queryVehiclePayRecordBO, pageBO);

        PageVO<VehiclePayRecordVO> pageVO = toPageVO.toPageVO(vehiclePayRecordBOPage, toVehiclePayRecordVO.toVehiclePayRecordVOList(vehiclePayRecordBOPage.getRecords()));
        return ResultJson.successWithResult(pageVO);
    }

}
